<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 单个栏目的业务 服务
 */
class Category_bo extends MY_Service {

    public $category_info = array();
    public $settings      = array();

    public function __construct() {
        parent::__construct();
        log_message('debug', 'Category_bo Service Class Initialized');
    }

    /**
     * 初始化
     *
     * @param int $category_id
     * @return $this
     */
    public function init($category_id) {
        $this->load->model('category_model');
        $this->category_info = $this->category_model->get($category_id);
        if (isset($this->category_info['settings'])) {
            $this->settings = $this->category_info['settings'];
        }
        return $this;
    }

    /**
     * 获取文档类型
     *
     * @param UserBo $user
     * @return array
     */
    public function get_doc_type(/*UserBo $user*/) {
        if (!is_array($this->settings['post_typeorder'])) return array();
        asort($this->settings['post_typeorder']);
        $array = array();
        $this->load->service('post/post_type_service');
        $type = $this->post_type_service->get_type();
        foreach ($this->settings['post_typeorder'] as $key => $value) {
            //if (isset($type[$key]) && in_array($key, $this->settings['post_allowtype']) && ($type[$key][2] === true || $user->getPermission($type[$key][2]))) {
            if (isset($type[$key]) && in_array($key, $this->settings['post_allowtype']) && ($type[$key][2] === true)) {
                $array[$key] = $type[$key];
            }
        }
        return $array;
    }
}

/* End of file Category_bo.php */
/* Location: ./application/services/doc/bo/Category_bo.php */
